//
//  OAuthService.m
//  SinaWebo
//
//  Created by Pink Elephant on 15/4/15.
//  Copyright (c) 2015年 亦心. All rights reserved.
//

#import "OAuthService.h"
#import "HttpUtil.h"
#import "OAuthResponse.h"
#import <MJExtension.h>

@implementation OAuthService
+(void)getOAuthDataWithRequest:(OAuthRequest *)request success:(void (^)(Account *))success failure:(void (^)(NSError *))failure{
    [HttpUtil postWithURL:getTokenURL params:request.mj_keyValues success:^(id responseObject) {
        if (success) {
            Account *result=[Account mj_objectWithKeyValues:responseObject];
            success(result);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

+ (void)getLoginDataWithRequest:(LoginRequest *)request success:(void (^)(LoginResponse *))success failure:(void (^)(NSError *))failure{
    NSString *url = @"https://api.weibo.cn/2/account/login?wm=3333_2001&i=1a457e4&b=1&from=1066193010&c=iphone&networktype=wifi&v_p=31&skin=default&v_f=1&lang=zh_CN&ua=iPhone7,2__weibo__6.6.1__iphone__os9.3.2&sflag=1&aid=01ArZc1HXWoVklRmXPZMEDhsL-yCZ_WOkNaf02DHmnzefX5w8.";
    [HttpUtil postWithURL:url params:request.mj_keyValues success:^(id responseObject) {
        if (success) {
            LoginResponse *result=[LoginResponse mj_objectWithKeyValues:responseObject];
            success(result);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}
@end
